home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / perlnt.zip / t / comp / arith.nt next >
Text File  |  1993-07-25  |  1KB  |  46 lines

  1. print "1..14\n";
  2.  
  3. $hard_pi = 3.1415926535897932384626433;
  4.  
  5. # arc tangent of x/y
  6. $pi = atan2(1, 1) * 4;
  7. if ($hard_pi == $pi) {print "ok 1\n";} else {print "not ok 1\n";}
  8.  
  9. # sine
  10. if (sin(0) == 0) {print "ok 2\n";} else {print "not ok 2\n";}
  11. if (sin($pi/2) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
  12.  
  13. # cosine
  14. if (cos(0) == 1) {print "ok 4\n";} else {print "not ok 4\n";}
  15. if (cos($pi) == -1) {print "ok 5\n";} else {print "not ok 5\n";}
  16.  
  17. # square root
  18. if (sqrt(144) == 12) {print "ok 6\n";} else {print "not ok 6\n";}
  19.  
  20. # integer
  21. if (int(123.456) == 123) {print "ok 7\n";} else {print "not ok 7\n";}
  22.  
  23. # natural log (log base e of x)
  24. if (log(1) == 0) {print "ok 8\n";} else {print "not ok 8\n";}
  25. $x = log(22026);
  26. if ($x > 9.99 && $x < 10.1) {print "ok 9\n";} else {print "not ok 9\n";}
  27.  
  28. # exponent (e^x)
  29. if (exp(0) == 1) {print "ok 10\n";} else {print "not ok 10\n";}
  30. $x = exp(10);
  31. if ($x > 22025.99 && $x < 22026.99) 
  32.     {print "ok 11\n";} else {print "not ok 11\n";}
  33.  
  34. # seed the random number generator
  35. srand (12345);
  36.  
  37. # now check some random numbers
  38. $x = rand(1);
  39. if ($x <= 1 && $x >= 0) {print "ok 12\n";} else {print "not ok 12\n";}
  40.  
  41. $x = rand(9);
  42. if ($x <= 9 && $x >= 0) {print "ok 13\n";} else {print "not ok 13\n";}
  43. $x = rand(9);
  44. if ($x <= 9 && $x >= 0) {print "ok 14\n";} else {print "not ok 14\n";}
  45.  
  46.